package org.example.auth.exception;

import org.example.common.base.util.web.AjaxResult;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version 1.0.0
 * @className: Oauth2ExceptionHandler
 * @description: 全局处理Oauth2抛出的异常
 * @author: LiJunYi
 * @create: 2023/4/3 17:08
 */
@ControllerAdvice
public class Oauth2ExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = OAuth2Exception.class)
    public AjaxResult oAuth2ExceptionHand(OAuth2Exception e) {
        return AjaxResult.error(e.getMessage());
    }
}
